WOLF core
WOLF: A Modular Estimation Framework for Robotics
XXXXXXXXXXXXXXXXXXXXXXXXvoid(0)" frameborder="0" name="MSearchResults" id="MSearchResults">
node_base.h
Go to the documentation of this file.
1// WOLF - Copyright (C) 2020-2026
2// Institut de Robòtica i Informàtica Industrial, CSIC-UPC.
3// Authors: Joan Solà Ortega (jsola@iri.upc.edu) and
4// Joan Vallvé Navarro (jvallve@iri.upc.edu)
5// All rights reserved.
6//
7// This file is part of WOLF: http://www.iri.upc.edu/wolf
8// WOLF is free software: you can redistribute it and/or modify
9// it under the terms of the GNU General Public License version 3
10// as published by the Free Software Foundation.
11//
12// This program is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with this program. If not, see <http://www.gnu.org/licenses/>.
19#pragma once
20
21// Wolf includes
22#include "core/common/wolf.h"
24
25namespace wolf
26{
74{
75 friend Problem;
76
77 private:
78 static unsigned int node_id_count_;
79
80 struct Serializer;
81
82 protected:
83 ProblemWPtr problem_ptr_;
84
85 unsigned int node_id_;
86 std::string node_category_;
87 std::string node_type_;
88 std::string node_name_;
90
92
93 virtual void setProblem(ProblemPtr _prob_ptr);
94
95 public:
96 NodeBase(const std::string& _category, const std::string& _type = "Undefined", const std::string& _name = "");
97 virtual ~NodeBase() = default;
98
99 unsigned int nodeId() const;
100 std::string getCategory() const;
101 std::string getType() const;
102 std::string getName() const;
103 bool isRemoving() const;
104 virtual bool hasChildren() const = 0;
105
106 void setType(const std::string& _type);
107 void setName(const std::string& _name);
108 ProblemConstPtr getProblem() const;
109 ProblemPtr getProblem();
110};
111
112} // namespace wolf
113
114#include <iostream>
115
116namespace wolf
117{
118inline NodeBase::NodeBase(const std::string& _category, const std::string& _type, const std::string& _name)
119 : problem_ptr_(), // nullptr
120 node_id_(++node_id_count_),
121 node_category_(_category),
122 node_type_(_type),
123 node_name_(_name),
124 is_removing_(false)
125{
126 //
127}
128
129inline unsigned int NodeBase::nodeId() const
130{
131 return node_id_;
132}
133
134inline std::string NodeBase::getCategory() const
135{
136 return node_category_;
137}
138
139inline std::string NodeBase::getType() const
140{
141 return node_type_;
142}
143
144inline std::string NodeBase::getName() const
145{
146 return node_name_;
147}
148
149inline bool NodeBase::isRemoving() const
150{
151 return is_removing_;
152}
153
154inline void NodeBase::setType(const std::string& _type)
155{
156 node_type_ = _type;
157}
158
159inline void NodeBase::setName(const std::string& _name)
160{
161 node_name_ = _name;
162}
163
164inline ProblemConstPtr NodeBase::getProblem() const
165{
166 return problem_ptr_.lock();
167}
168
169inline ProblemPtr NodeBase::getProblem()
170{
171 return problem_ptr_.lock();
172}
173
174inline void NodeBase::setProblem(ProblemPtr _prob_ptr)
175{
176 problem_ptr_ = _prob_ptr;
177}
178
179} // namespace wolf
Base class for Nodes.
Definition: node_base.h:74
std::string node_type_
Text label identifying the type or subcategory of node ("Pin Hole", "Point 2d", etc)
Definition: node_base.h:87
unsigned int node_id_
Node id. It is unique over the whole Wolf Tree.
Definition: node_base.h:85
bool isRemoving() const
Definition: node_base.h:149
std::string node_category_
Text label identifying the category of node ("SENSOR", "FEATURE", etc)
Definition: node_base.h:86
std::string getType() const
Definition: node_base.h:139
bool is_removing_
A flag for safely removing nodes from the Wolf tree. See remove().
Definition: node_base.h:91
void setName(const std::string &_name)
Definition: node_base.h:159
std::string getName() const
Definition: node_base.h:144
unsigned int nodeId() const
Definition: node_base.h:129
std::string node_name_
Definition: node_base.h:88
ProblemWPtr problem_ptr_
Definition: node_base.h:83
virtual ~NodeBase()=default
std::string getCategory() const
Definition: node_base.h:134
virtual void setProblem(ProblemPtr _prob_ptr)
Definition: node_base.h:174
void setType(const std::string &_type)
Definition: node_base.h:154
NodeBase(const std::string &_category, const std::string &_type="Undefined", const std::string &_name="")
Definition: node_base.h:118
ProblemConstPtr getProblem() const
Definition: node_base.h:164
virtual bool hasChildren() const =0
Definition: problem.h:62
Definition: capture_base.h:23